#测试浅拷贝和深拷贝
import copy

def testCopy():
    '''测试浅拷贝'''
    a=[10,20,[5,6]]
    b=copy.copy(a)

    print("a,",a)
    print("b,",b)
    b.append(30)
    b[2].append(7)      #由于浅拷贝是同一个子对象，所以改变b的子对象a也会有相应的改变
    print('浅拷贝后，b改变......')
    print("a,", a)
    print("b,", b)


def testDeepcopy():
    '''测试深拷贝'''
    a = [10, 20, [5, 6]]
    b = copy.deepcopy(a)
    print("a,", a)
    print("b,", b)
    b.append(30)
    b[2].append(7)      #由于浅拷贝不是同一个子对象，所以改变b的子对象a也不会有相应的改变
    print('深拷贝后，b改变......')
    print("a,", a)
    print("b,", b)

testCopy()
print("**************")
testDeepcopy()